package com.test.filter.config;


import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * 使用Servlet提供的注解@WebFilter 需要在启动类上加@ServletComonentScan
 */
@WebFilter(filterName = "customerFilter3",urlPatterns = "/*")
@Order(3)
@Slf4j
public class CustomFilter3 implements Filter {

    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("执行被@Component标注的CustomFilter3的init方法");
    }

    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("执行被@Component标注的CustomFilter3的doFilter方法");
        filterChain.doFilter(servletRequest, servletResponse);
    }

    public void destroy() {
        log.info("执行被@Component标注的CustomFilter3的destroy方法");
    }
}
